// detail
import React, { Component } from 'react'
import qs from 'querystring'
export default class Detail extends Component {
    state={
        detailDatas:[{id:0,content:'内容1'},{id:1,content:'内容2'},{id:2,content:'内容3'}]
    }
    myPush=(n)=>{
        console.log(1);
        console.log(n);
    }
    render() {
        console.log(this.props);
        const {state}=this.props.history.location
        /* console.log('props',this.props.location.search);
        const {id,title}=qs.parse(this.props.location.search.slice(1))
        console.log(qs.parse(this.props.location.search.slice(1)));
        console.log(id,title); */
        /* console.log(this.props.match.params);
        const {id}=this.props.match.params
        //类似于filter写法 */
        const {detailDatas}=this.state
        const data=detailDatas.find(item=>{
            // console.log(item);
            return item.id==state.id
        })
        console.log('data',data);
        return (
            <div>
                {/* <span>id:{data.id}内容：{data.content}</span> */}
                <span>id:{data.id}内容：{data.content}</span>
                <button onClick={()=>{this.myPush(1)}}>push手动跳转</button>
            </div>
        )
    }
}
